<template>
	<view class="integral">
		<view class="current_integral">
			<text class="current">当前积分：</text>
			<text class="number">{{integral_number || 0}}</text>
			<text class="detailed" @click="gotodetail">积分明细</text>
			<text class="detailed rule" @click="gotorule">积分规则</text>
		</view>
		<view class="user" v-if="account_type=='工人'||account_type=='班组长'">
			<!-- <view class="authentication">
				<text>1</text>
				<text>用户完成注册</text>
				<text :class="completion_status.name_authentic=='已完成' ? 'success':'' "
					@click="toRegister(completion_status.name_authentic?completion_status.name_authentic:'去完成')">{{completion_status.name_authentic||'去完成'}}</text>
			</view>
			<view class="baseinfo">
				<text>2</text>
				<text>用户完成实名认证</text>
				<text :class="completion_status.PerfectInformation=='已完成' ? 'success':'' "
					@click="toAuthentication(completion_status.PerfectInformation?completion_status.PerfectInformation:'去完成')">{{completion_status.PerfectInformation||'去完成'}}</text>
			</view>
			<view class="learn_video">
				<text>3</text>
				<text>用户学习安全视频</text>
				<text :class="completion_status.LearnVideo=='已完成' ? 'success':'' "
					@click="toLearn(completion_status.LearnVideo?completion_status.LearnVideo:'去完成')">
					{{completion_status.LearnVideo||'去完成'}}
				</text>
			</view> -->

			<view class="authentication">
				<text>1</text>
				<text>用户完成注册</text>
				<text :class="completion_status.name_authentic=='已完成' ? 'success':'' "
					@click="toRegister(completion_status.name_authentic?completion_status.name_authentic:'去完成')">{{completion_status.name_authentic||'去完成'}}</text>
			</view>
			<view>
				<text>2</text>
				<text>用户完成实名认证</text>
				<text :class="completion_status.PerfectInformation=='已完成' ? 'success':'' "
					@click="toAuthentication(completion_status.PerfectInformation?completion_status.PerfectInformation:'去完成')">{{completion_status.PerfectInformation||'去完成'}}</text>
			</view>
			<view class="baseinfo">
				<text>3</text>
				<text v-if="account_type=='工人'">用户完善个人基本信息</text>
				<text v-else>用户完善班组基本信息</text>
				<text :class="completion_status.PersonalInformation=='已完成' ? 'success':'' "
					@click="toBaseinfo(completion_status.PersonalInformation?completion_status.PersonalInformation:'去完成')">{{completion_status.PersonalInformation||'去完成'}}</text>
			</view>
			<view class="learn_video">
				<text>4</text>
				<text>用户学习安全视频</text>
				<text :class="completion_status.LearnVideo=='已完成' ? 'success':'' "
					@click="toLearn(completion_status.LearnVideo?completion_status.LearnVideo:'去完成')">
					{{completion_status.LearnVideo||'去完成'}}
				</text>
			</view>
		</view>
		<view class="user" v-else>
			<view class="authentication">
				<text>1</text>
				<text>用户完成注册</text>
				<text class="success">去完成</text>
			</view>
			<view>
				<text>2</text>
				<text>用户完成实名认证</text>
				<text class="success">去完成</text>
			</view>
			<view class="baseinfo">
				<text>3</text>
				<text>用户完善个人基本信息</text>
				<text class="success">去完成</text>
			</view>
			<view class="learn_video">
				<text>4</text>
				<text>用户学习安全视频</text>
				<text :class="completion_status.LearnVideo=='已完成' ? 'success':'' "
					@click="toLearn(completion_status.LearnVideo?completion_status.LearnVideo:'去完成')">
					{{completion_status.LearnVideo||'去完成'}}
				</text>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '@/static/js/api.js'

	export default {
		data() {
			return {
				integral_number: 0,
				completion_status: [],
				account_type: ''
			}
		},
		onShow() {
			this.getdata()
			this.account_type = JSON.parse(uni.getStorageSync('userInfo')).account_type
		},
		mounted() {},
		methods: {
			gotodetail() {
				uni.navigateTo({
					url: '/pagesB/integral/integralSubsidiary'
				})
			},
			gotorule() {
				uni.navigateTo({
					url: '/pagesB/integral/integralrules'
				})
			},
			getdata() {
				var uid = JSON.parse(uni.getStorageSync('userInfo')).uid
				var access_token = JSON.parse(uni.getStorageSync('userInfo')).access_token;
				api.currentIntegral(access_token, 'integral.detail', '_api_integral_tasks', uid).then(res => {
					this.completion_status = res.data
					this.integral_number = res.data.integral_number
				})
			},
			toRegister(params) {
				if (params == '去完成') {
					// uni.navigateTo({
					// 	url: '/pagesB/integral/integralrules'
					// })
				}
			},
			toAuthentication(params) {
				if (params == '去完成') {
					uni.navigateTo({
						url: '/pages/main/mine/Attestation'
					})
				}
			},
			toBaseinfo(params) {
				if (params == '去完成') {
					uni.navigateTo({
						url: '/pages/main/mine/PerfectInformation'
					})
				}
			},
			toLearn(params) {
				if (params == '去完成') {
					uni.navigateTo({
						url: '/pages/home/class/ClassPage'
					})
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.integral {
		.current_integral {
			height: 220rpx;
			margin: 36rpx 0 0 40rpx;
			position: relative;

			.current {
				color: #666666;
			}

			.number {
				color: #DACF1E;
				font-size: 60rpx;
				font-weight: bold;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
			}

			.detailed {
				background: #F8EC2B;
				padding: 10rpx;
				border-radius: 30rpx 0 0 30rpx;
				position: absolute;
				top: 0;
				right: 0;
			}

			.rule {
				top: 35%;
				right: 0;
			}
		}

		.user {
			& view:not(:first-child) {
				margin-top: 20rpx;
			}

			view {
				display: flex;
				padding: 0 40rpx;
				align-items: center;

				& text:first-child {
					background: #FF3636;
					color: #fff;
					border-radius: 50%;
					width: 40rpx;
					height: 40rpx;
					display: inline-block;
					text-align: center;
					line-height: 40rpx;
				}

				& text:nth-child(2) {
					margin-left: 20rpx;
					flex: 1;
				}

				& text:last-child {
					color: #fff;
					background: #FF3636;
					border-radius: 6rpx;
					padding: 8rpx 16rpx;
				}

				text.success {
					background: #E7E7E7;
					color: #6C6C6C;
				}
			}

		}
	}
</style>
